//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "ProcessEpitopesAndLINGOs.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  String* filenameLigandEpitope = NULL;
  String* filenameOut           = NULL;
  int     cutoff                = 40;
  
  if (argc < 4) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./HowOftenCombinationLINGOSEpitopes <In File - Ligand - Epitopes Comparison>";
    cout <<                                    " <Out File>";
    cout <<                                    " <Meta-Structure Alignment CutOff>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    filenameLigandEpitope = new String(argv[1]);
    filenameOut           = new String(argv[2]);
    cutoff                = atoi(argv[3]);
    
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    cout << " In File - Ligand - Epitopes Comparison : " << argv[1] << endl;
    cout << "                               Out File : " << argv[2] << endl;
    cout << "        Meta-Structure Alignment CutOff : " << argv[3] << endl;
    cout << "------------------------------------------------------------------------------------------------------" << endl;
    
  }
  
  ProcessEpitopesAndLINGOs* processEpitopesAndLINGOs = new ProcessEpitopesAndLINGOs ();
  
  cout << "Preparing Files..." << endl;
  processEpitopesAndLINGOs->FilenameIn(filenameLigandEpitope);
  processEpitopesAndLINGOs->FilenameOut(filenameOut);
  
  cout << "Loading the data..." << endl;
  
  if (!processEpitopesAndLINGOs->LoadDataLigandEpitopeLINGO())
    cout << "Error Loading data!" << endl;
  
  cout << "Computing how often common LINGOs combinations are found for epitopes MT alignment..." << endl;
  processEpitopesAndLINGOs->HowOftenAParticularLingoCombinationIsFound(cutoff);
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (processEpitopesAndLINGOs) delete processEpitopesAndLINGOs;
  
  if (filenameLigandEpitope)    delete filenameLigandEpitope;
  if (filenameOut)              delete filenameOut;

  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

